#ifndef Catalog_H
#define Catalog_H

#include <qfile.h>

#include <QAbstractTableModel>
#include <QString>

#include <vector>
#include <set>

#include "StarEntry.h"

struct classstarcomp {
  bool operator() (StarEntry * const& lhs, StarEntry * const& rhs) const
  {return lhs->htmid <rhs->htmid;}
};

class Catalog: public QAbstractTableModel {
  Q_OBJECT
public:
  
  void setDatafileName(QString);
  void setEpoch(double epoch);
  virtual void loadData();
  std::vector<StarEntry *> *getStars();
  std::set<StarEntry *, classstarcomp> *getStarSet();
  
  int rowCount(const QModelIndex& parent) const;
  int columnCount(const QModelIndex& parent) const;
  QVariant data(const QModelIndex& index, int role) const;
  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
  
protected: 
  QFile datafile;
  double epoch; // Julian Day Epoch, see libnova
  QString *prefix;
  std::vector<StarEntry *>stars;
  std::set<StarEntry *, classstarcomp>starset;

private:
  static int format_sexa(char *out, double a, int w, int fracbase);  // from indicode.c  
};

#endif // Catalog_H
